<template>
  <div class="app-container">
    <el-form :model="selectForm" ref="queryForm" :inline="true" label-width="80px">
      <el-form-item label="验收编号">
        <el-input
          v-model="selectForm.acceptCode"
          placeholder="请输入验收编号"
          clearable
          @keyup.enter.native="getList"
        />
      </el-form-item>
      <el-form-item label="设备名称">
        <el-input
          v-model="selectForm.deviceName"
          placeholder="请输入设备名称"
          clearable
          @keyup.enter.native="getList"
        />
      </el-form-item>
      <el-form-item label="出厂编号">
        <el-input
          v-model="selectForm.factoryCode"
          placeholder="请输入出厂编号"
          clearable
          @keyup.enter.native="getList"
        />
      </el-form-item>
      <el-form-item label="规格型号">
        <el-input
          v-model="selectForm.deviceModel"
          placeholder="请输入型号"
          clearable
          @keyup.enter.native="getList"
        />
      </el-form-item>
      <el-form-item label="负责人">
        <el-input
          v-model="selectForm.chargeUserName"
          placeholder="请输入负责人"
          clearable
          @keyup.enter.native="getList"
        />
      </el-form-item>
      <el-form-item label="类别">
        <treeSelect @deviceType="deviceTypeChange" type="deviceType"></treeSelect>
      </el-form-item>
      <el-form-item label="存放位置">
        <treeSelect @deviceRepo="deviceRepoChange"   type="deviceRepo"></treeSelect>
    </el-form-item>
      <el-form-item label="品牌">
        <el-input
          v-model="selectForm.deviceBrandName"
          placeholder="请输入品牌"
          clearable
        />
      </el-form-item>
      <el-form-item label="所属部门">
        <treeSelect @department="departmentChange" type="department"></treeSelect>
      </el-form-item>
      <el-form-item>
        <el-checkbox v-model="selectForm.isAcceptanceCompleted" @change="getList" >显示验收完成设备</el-checkbox>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="getList" v-hasPermi="['purchaseGL:equipmentDYS:search']">搜索</el-button>
      </el-form-item>
    </el-form>
    <el-table v-loading="loading" :data="list.rows" stripe>
      <el-table-column align="center" type="index" label="序号" width="55"/>
      <el-table-column align="center" label="编号" property="acceptId" />
      <el-table-column align="center" label="设备名称" property="deviceName" :show-overflow-tooltip="true"/>
      <el-table-column align="center" label="设备分类" property="deviceTypeName" :show-overflow-tooltip="true" />
      <el-table-column align="center" label="出厂编号" property="factoryCode" />
      <el-table-column align="center" label="品牌" property="deviceBrandName" :show-overflow-tooltip="true"></el-table-column>
      <el-table-column align="center" label="规格型号" property="deviceModel" :show-overflow-tooltip="true"></el-table-column>
      <el-table-column align="center" label="生产厂家" property="supplierName" :show-overflow-tooltip="true"></el-table-column>
      <el-table-column align="center" label="购置日期" property="buyDate" :show-overflow-tooltip="true"></el-table-column>
      <el-table-column align="center" label="购置金额" property="buyMoney" :show-overflow-tooltip="true"></el-table-column>
      <el-table-column align="center" label="负责人" property="chargeUserName" :show-overflow-tooltip="true"></el-table-column>
      <el-table-column align="center" label="存放位置" property="repositoryName" :show-overflow-tooltip="true" />
      <el-table-column align="center" label="所属部门" property="departmentName" :show-overflow-tooltip="true" />
      <el-table-column align="center" label="最新验收" property="acceptTypeName" :show-overflow-tooltip="true"></el-table-column>
      <el-table-column align="center" label="验收时间" property="acceptDate" :show-overflow-tooltip="true"></el-table-column>
      <el-table-column align="center" label="下步验收" property="nextStepAcceptTypeName" :show-overflow-tooltip="true"></el-table-column>
    </el-table>
    <pagination
      :total="list.total?list.total:0"
      :page.sync="selectForm.pageNum"
      :limit.sync="selectForm.pageSize"
      @pagination="getList"
    />

  </div>
</template>

<script>
  import { deviceAcceptStay } from '@/api/purchase/index'
  import treeSelect from '@/views/equipmentGL/equipmentTZ/treeSelect'

  export default {
    components: {
        treeSelect,
    },
    data() {
      return {
        list:[],
        loading: false,
        list: [],
        selectForm: {
          pageNum: 1,
          pageSize: 10,
          acceptCode: '',
          deviceName: '',
          factoryCode:'',
          deviceModel:'',
          chargeUserName:'',
          deviceBrandName:'',
          deviceTypeId:'',
          repositoryId:'',
          departmentId:'',
          applyEndTime: '',
          isAcceptanceCompleted:false
        },
      }
    },
    created() {
      this.getList()
    },
    methods: {
      /** 查询角色列表 */
      async getList() {
        this.loading = true
        let res = await deviceAcceptStay(this.selectForm)
        this.list = res
        this.loading = false
      },
      /** 获取设备分类的值*/
      deviceTypeChange(data) {
        this.selectForm.deviceTypeId = data.id
        this.getList()
      },
      /** 获取所属部门的值*/
      departmentChange(data) {
        this.selectForm.departmentId = data.id
        this.getList()
      },
      /** 获取存放位置*/
      deviceRepoChange(data){
        this.selectForm.repositoryId = data.id
        this.getList()
      },


    }
  }
</script>
